﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace SQLTouch.Client.Metro.View
{
    public class SwappingTextBox : TextBox
    {
        public string Text2
        {
            get { return (string)GetValue(Text2Property); }
            set { SetValue(Text2Property, value); }
        }

        public static readonly DependencyProperty Text2Property =
            DependencyProperty.Register("Text2", typeof(string),
            typeof(SwappingTextBox), new PropertyMetadata(string.Empty, OnText2Changed));

        private static void OnText2Changed(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
        {
            ((SwappingTextBox)sender).OnText2Changed((string)eventArgs.OldValue, (string)eventArgs.NewValue);
        }

        public SwappingTextBox()
        {
            TextChanged += Text2Box_TextChanged;
        }

        private void OnText2Changed(string oldValue, string newValue)
        {
            Text = newValue ?? string.Empty;
        }

        private void Text2Box_TextChanged(object sender, TextChangedEventArgs e)
        {
            Text2 = Text;
        }
    }
}
